WorldInfo = class()

function WorldInfo:init(length,height,name,seed,createdTime)
    self.length = length
    self.height = height
    self.name = name or "New World"
    self.createdTime = createdTime or date.getDateString()
    self.lastPlayed = self.createdTime
    self.seed = seed
    self.spawnX,self.spawnZ = self:getRandomSpawnPos()
    self.time = 0
    self.mode = WorldMode.Normal
    self.flatSample = nil   -- 超平坦的
end

-- 返回世界的大小(长，高)
function WorldInfo:getSize()
    return self.length,self.height
end

function WorldInfo:setName(name)
    self.name = name
end

function WorldInfo:getRandomSpawnPos()
    return 0,0
end

function WorldInfo:setFlatSample(flatSample)
    self.mode = WorldMode.Flat
    self.flatSample = flatSample
end

function WorldInfo:generateData()
    local t = {
    name = self.name,
    length = self.length,
    height = self.height,
    createdTime = self.createdTime,
    seed = self.seed,
    spawnX = self.spawnX,
    spawnZ = self.spawnZ,
    time = self.time,
    lastPlayed = self.lastPlayed,
    mode = self.mode,
    flatSample = self.flatSample
    }
    return t
end

function WorldInfo:readData(t)
    for k,v in pairs(t) do
        self[k] = v
    end
end